/* @(#)Bbs.java    V1.0
 *
 * Project: APEP
 *
 * Modify Information:
 * =============================================================================
 *   Author       Date       Description
 *   ------------ ---------- ---------------------------------------------------
 *   wangp    {CREATE_TIME} First release
 *
 * Copyright Notice:
 * =============================================================================
 *    Copyright (c) 2001-2007 Auto-Parts E-Procurement Co., Ltd.
 *        No.251-1 Wuning Road, Shanghai, 200063, China All rights reserved.
 *
 *    This software is the confidential and proprietary information of
 *        Auto-Parts E-Procurement Co., Ltd. ("Confidential Information").
 *        You shall not disclose such Confidential Information and shall use it
 *        only in accordance with the terms of the license agreement you entered
 *        into with APEP.
 *
 * Warning:
 * =============================================================================
 * 
 * 
 */

package system.base;

import system.data.BbsBase;
import framework.core.Conditions;
import framework.core.DBConnection;
import framework.core.DBEngine;
import framework.core.DBResult;
import framework.core.ObjectList;

/*
	Author    :wangp
	CreateTime:{CREATE_TIME}
 */
public class Bbs extends BbsBase
{

	public static final int FIRST_SUBJECT = 0;


	private static final long serialVersionUID = 1L;
	//----system generated start----//
	private static final String SEQ_NAME = "S_BBS";
	public Bbs()
	{

	}

	private static void delete(DBConnection con,int id) throws Exception
	{
		Conditions conditions = new Conditions();

		conditions.add(ID,id);

		delete(con,TABLE_NAME,conditions);
	}
	public static Bbs fetch()
	{
		return new Bbs();
	}
	public static Bbs copy(Bbs srcObj)
	{
		Bbs obj = fetch();
		obj.copyBase(srcObj);
		return obj;
	}
	public static Bbs fetch(DBConnection con,int id) throws Exception
	{
		Conditions conditions = new Conditions();

		conditions.add(ID,id);

		return fetch(con,conditions);
	}
	public static Bbs fetch(DBConnection con,Conditions conditions) throws Exception
	{
		DBResult result = null;
		try
		{
			result = DBEngine.doSelect(con,"select * from " + TABLE_NAME,conditions);
			java.sql.ResultSet rs = result.getRs();
			Bbs obj = null;
			if(rs.next())
			{
				obj = fetch(rs);
			}
			return obj;
		}
		finally
		{
			if(result!=null) {
				result.clear() ;
			}
		}
	}
	public static Bbs fetch(java.sql.ResultSet rs) throws Exception
	{
		Bbs obj = new Bbs();
		obj.initObject(rs);
		return obj;
	}
	protected void getUnique(DBConnection con) throws Exception
	{
		setId(DBEngine.getId(con,SEQ_NAME));
	}
	//----system generated end----//


	public static ObjectList getListByRootId(DBConnection con, int id) throws Exception {
		Conditions cs = new Conditions();
		cs.add("(Rel_id = ? or id = ?)", Conditions.CUSTOM, new int[]{id, id});
		cs.add("1=1 order by id ");
		return fetch().search(con, cs);
	}
}

